package com.sunwoda.springbootshiro.autotask;

import com.sunwoda.springbootshiro.bean.UserBean;
import com.sunwoda.springbootshiro.entity.User;
import com.sunwoda.springbootshiro.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @program: springboot-shiro
 * @description: 自动任务
 * @author: SGR
 * @create: 2021-09-16 15:04
 **/
@Configuration
@EnableScheduling  //开启自动任务
@Slf4j
public class StaticScheduleTask {

    /** 
    * @Description:  
    * @Param:  
    * @return:  
    * @Author: SGR 
    * @Date: 2021-09-16 
    */
//    添加自动任务
    @Scheduled(cron = "0 0/10 * * * ?")
    private void configureTasks(){
        UserServiceImpl userService = UserBean.uService;
        List<User> list = userService.getAll(new User());
        if (CollectionUtils.isEmpty(list)){
            log.info("list为空");
        }
    }

}
